package com.my.ouput;

import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * @author marshal
 * @date 2021-05-25 8:22 PM
 */
public class FileOutputStreamTest {
    public static void main(String[] args) {
        try (var fi = new FileInputStream("file/poem.txt");
             var fo = new FileOutputStream("file/poem_copy.txt");) {
            var bbuf = new byte[32];
            var hasRead = 0;
            while ((hasRead = fi.read(bbuf)) > 0) {
                // 读取多少，就写入多少
                fo.write(bbuf, 0, hasRead);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}
